<template>
  <div>
    <div class="header">
      <span>申诉</span>
      <a href="javascript:history.go(-1)" class="return"></a>
    </div>
    <div style="height: 1rem;"></div>

    <div class="ywc">
      <p>申诉</p>
    </div>

    <textarea name v-model="textareatext" id="content" cols="100%" rows="10"></textarea>

    <div style="height: 1rem;"></div>

    <div class="img_img">
      <!-- <span>图片</span> -->
      <div class="weui-uploader__input-box">
        <input
          id="uploaderInput"
          class="weui-uploader__input"
          type="file"
          @change="addImg"
          ref="inputer"
          accept="image/*"
          multiple
          text-indent="100%"
        >
      </div>
    </div>
    <div class="wszjxx" @click="push" style="margin-bottom: .4rem">
      <button class="tjssb" type="submit" id="bb">提交</button>
    </div>
  </div>
</template>
<script>
import { setTimeout } from "timers";
export default {
  data() {
    return {
      path: "",
      textareatext: ""
    };
  },
  methods: {
    addImg() {
      var inputDOM = this.$refs.inputer.files[0];
      var formData = new FormData();
      formData.append("file", inputDOM);
      var config = {
        headers: { "Content-Type": "multipart/form-data" }
      };
      this.$axios
        .post("/index/upload/uploadimg", formData, config)
        .then(response => {
          if (response.data.code === 0) {
            this.path = response.data.data;
            //    this.$createToast({ txt:"response.data.msg", type: 'txt' }).show();
          } else {
            this.$createToast({ txt: "网络错误", type: "txt" }).show();
          }
        });
    },
    push() {
      if (!this.$route.query.id) {
        this.$createToast({ txt: "id没有", type: "txt", time: 1000 }).show();
        return;
      } else if (!this.textareatext) {
        this.$createToast({
          txt: "请输入内容",
          type: "txt",
          time: 1000
        }).show();
        return;
      } else if (!this.path) {
        this.$createToast({
          txt: "请上传图片",
          type: "txt",
          time: 1000
        }).show();
        return;
      }
      this.$axios
        .post("/index/otcexchange/explains", {
          orderid: this.$route.query.id,
          content: this.textareatext,
          path: this.path
        })
        .then(res => {
          this.$createToast({
            txt: res.data.msg,
            type: "txt",
            time: 1200
          }).show();
          if (res.data.code == 0) {
            setTimeout(() => {
              this.$router.back(-1);
            }, 1200);
          }
        });
    }
  }
};
</script>


<style lang="less" scoped>
@import url("../less/otcappeal");
</style>


